May 25 1987 GFATIP02.DOC Constructing a System Drive Map By John B. Holder Senior Software Engineer, Marathon Computer Press This is the second in a planned series of tips on how to get the most out of your GFA Basic Interpreter/Compiler. The topic is Mapping your System. What this means in plain english is: "Determining how many logical drives are connected to the system". Why do we need to know that you may ask? Unless you will never write programs for anyone besides yourself, this will be a good technique to learn for reasons described below. What will this do? Well, it will give you a binary presentation of your system's drive status. Imagine each drive hooked up to the system as a single digit. By this I mean that if you have 3 drives attached to the machine the drive map will be represented by the symbols 111. If there were 10 drives connected to the system the drive map would be 1111111111. Starting to make sense? Now it gets a little complicated. So you say, Wow! that's great; all we have to do now is call the Drive_map procedure and get Len(Num$) to find out which drives are attached. Not completely true. If the user has 4 drives attached and they are in the sequence of A B C D then you could do that. But the first problem comes into play when you consider that the BIOS always returns a value of 11 for drives attached. That's so you can make those handy dandy full disk backups by dragging Icon A to Icon B and sit back while it copies all of the files for you. So if it always returns a signal that says that Drive B is connected whether or not it really is, how do you get around it? Well, the answer is you don't. The operating system handles this condition by telling the user to insert disk B into Drive A and vice versa to get around it. So not all's bad with this condition. Ok, so we can now accept the fact that we'll always get a return of at least 11 no matter what. Now how do we tell if another drive is missing or out of order? At this point we must go back to the above analogy of 1 digit per drive. Take the following configuration: A B C D _ F The underscore is represented above to show that the user has somehow managed to install a Ram Drive or something in Drive F's slot, thus bypassing drive E. Now if you call the Drive_map procedure and use: Print Len(Num$) You'll see a 6 appear on the screen, but we know right off that it's not right {because we cheated and saw which drives were connected, after all we own the machine right?}. But if you use: Print Num$ You will now see the system as it really exists. The following will appear on the screen 101111 Pretty handy if you don't want your latest and greatest program to hopelessly crash because Joe BetaTester had a Ram Drive out of Normal Sequence. Now getting an actual picture of the system is as simple as: @Drive_map ! Gosub Drive_map For X =0 To Len(Num$)-1 step 1 If Mid$(Num$,Len(Num$)-X,1)="1" Print "Drive ";Chr$(Asc("A")+X);" Is Online" Else Print "Drive ";Chr$(Asc("A")+X);" Not Connected!" Endif Next X I hope this little routine and explanation of how it works will assist you in getting the most out of your investment in a wonderful Interpreter and Compiler. Comments are welcome, good or bad. I've included the sample source code in a Basic .BAS file in the archive for you to run as is. Have fun! John B. Holder GRIFJOHN Here's the actual procedure and some commented source code: ' Drive_map Returns two values for you; they are: ' Num% = a bit vector containing active drives ' Num$ = a binary representation of connected drives ' If you had drives A,B,C connected num%=7 and num$=111 ' In this way you can count up the active drives from A-P by ' looking at the resulting bit vector representation. ' If drives are not in order there may be zeros in between ' numbers. Example: You have drive A & B, plus a Ram Drive M ' M__________BA ' drive map = 1000000000011 ' ' Or the more classical situation: ' CBA ' drive map = 111 ' ' ' Example: @Drive_map Print Num% Print Num$ ' ' Procedure Drive_map Num%=Bios(10) Num$=Bin$(Num%) Return